#!/bin/sh

FILEMODES="/sys/class/graphics/fb0/modes"

f_usage() {
	echo "$0 currentMode" >&2
	echo "$0 currentResolution" >&2
}

if [ $# -eq 0 ]; then
	f_usage
	exit 1
fi

# use for syntax only
PSCREEN=
if test "${1}" = "--screen"
then
    shift
    PSCREEN=$1
    shift
fi

ACTION=$1
shift

case "${ACTION}" in
    "supportSystemRotation")
	exit 1
    ;;
    "supportSystemReflection")
	exit 1
    ;;
    "listModes")
    ;;
    "setMode")
    ;;
    "minTomaxResolution" | "minTomaxResolution-secure")
    ;;
    "currentMode"|"currentResolution")
        # mode can be different from resolution (ie on rpi)
        test -e "${FILEMODES}" && head -1 "${FILEMODES}" | sed -e s+'^[^:]:\([0-9]*\)x\([0-9]*\)[a-z]*.*$'+'\1x\2'+
        ;;
	*)
		f_usage
		>&2 echo "error: invalid command ${ACTION}"
		exit 1
esac
exit 0
